<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta charset="UTF-8">
  <title>随手拍详情</title>
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../css/common.css">
  <script type="text/javascript" src="../lib/js/evm.js"></script>
  <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
  <script type="text/javascript" src="../lib/js/key.js"></script>
  <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
  <style>
    .wordDetail-bg {
      width: 1280px;
      height: 720px;
      background: url(../images/bg-1.png) no-repeat left top;

    }

    .model {
      box-sizing: border-box;
      border: 3px solid transparent;
    }

    #wordDetailBody {
      width: 100%;
      height: 100%;
    }

    #detailContain {
      color: white;
      position: absolute;
      top: 215px;
      right: 60px;
      width: 565px;
      height: 329px;
      /* padding: 20px 30px; */
      background: rgba(0, 0, 0, .3);
      border-radius: 8px;
    }
    #detail {
      width: 100%;
      height: 100%;
    }

    .user-header {
      width: 80px;
      height: 80px;
      border-radius: 50%;
      position: absolute;
      left: 10px;
      top: 10px;
    }
    .user-header img {
      width: 100%;
      left: 100%;
    }

    .username {
      width: auto;
      font-size: 28px;
      position: absolute;
      left: 100px;
      top: 15px;
      height: 36px;
      line-height: 36px;
    }

    .time {
      width: auto;
      font-size: 24px;
      position: absolute;
      left: 100px;
      top: 55px;
      height: 36px;
      line-height: 36px;
    }
    
    .brief {
      width: 520px;
      height: 70px;
      line-height: 35px;
      font-size: 28px;
      position: absolute;
      top: 90px;
      left: 10px;
      overflow: hidden;
    }

    .content {
      width: 528px;
      height: 130px;
      position: absolute;
      bottom: 15px;
      left: 10px;
      font-size: 24px;
    }

    .like {
      position: absolute;
      width: 70px;
      height: 70px;
      right: 10px;
      top: 10px;
      text-align: center;
      border: 3px solid transparent;

      box-sizing: border-box;
    }

    .like img {
      width: 40px;
      height: 40px;
    }

    /*左侧图片*/
    #left-border {
      width: 585px;
      height: 329px;
      background: rgba(0, 0, 0, .3);
      border-radius: 8px;
      position: absolute;
      top: 215px;
      left: 60px;
      /* border: 1px solid rgba(112, 112, 112, 1); */
    }

    #left-border>img {
      width: 100%;
      height: 100%;
      border-radius: 10px;
    }
    .active {
      border: 3px solid orange;
    }
    #detailContain.active {
      border: 3px solid transparent;

    }

    #detailContain.active .like {
      border: 3px solid orange;
    }
  </style>
</head>

<body>
  <div class="wordDetail-bg" id="wordDetailMain">

    <div id="wordDetailBody">
      <div class="model" id="left-border"><img src="" alt=""></div>
      <div class="model" id="detailContain">
        <div class="container" id="detail">
          <div class="user-header"><img src="../images/user-logo.png" alt=""></div>
          <div class="username"></div>
          <div class="time"></div>
          <div class="brief"></div>
          <div class="content"></div>
        </div>
        <div class="like">
          <img src="../images/like-1.png" alt="">
          <p class="like-num">0</p>
        </div>
      </div>
    </div>
  </div>
</body>
<script>
  var modelIndex = {
    disUser: true,
    // isVideo: true,
    index: 0, //初始位置
    listName: 'model', //模块名称
    containerId: 'wordDetailBody', //包含模块的标签id
    thisContain: 'detailContain', //翻滚外容器
    thisDetail: 'detail', //翻滚内容
  }

  // setTimeout(function () {
  //   direOpt(1, 'down')
  // }, 500);

  TV.structure('随手拍')
  var articleRun;
  var photos;

  function direOpt(index, directive) {
    if (directive == "backwards") { //左
      // TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
      index = (index == 1 ? 0 : 1);
    } 
    else if (directive == "forwards") { //右
      // TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
      index = (index == 0 ? 1 : 0);
    }
    return index;
  }

  function getMessage() {
    var param = {
      id: TV.GetParam('id'),
      // area_id: $.cookie('TV_CST_AREA')
    }
    GetDatas('photoDetail', param, function (err, res) {
      var mess = res.data;
      console.log(mess)
      $('.username').html(mess.username)
      $('.time').html(mess.addtime)
      $('.brief').html(mess.title)
      $('.content').html(mess.content)
      $('.like-num').html(mess.likes)
      if(mess.img && mess.img.length){
        $('#left-border>img').attr('src', API_URL['imgURL'] + mess.img[0])
      }else{
        $('#left-border>img').attr('src', '../images/base.png')
      }
      

    })
  }
  getMessage();

  function direEnter(index) {
    if (index == 0) {
      window.location.href = './A_DetailPhoto.html?id=' + TV.GetParam('id')+'&type=photo';
    }
    else if (index == 1) {
      var access_token = $.cookie('TV_CST_TOKEN');
      var param = {
        id: TV.GetParam('id'),
        access_token: access_token,
      }
      GetDatas('eventLike', param, function (err, res) {
        console.log(res)
        if (res.code == 0) {
          TV.PromptMsg('点赞成功')
          $(".like-num").html(res.data.likes);
          $('#like').css('background-image', 'url(../images/like-2.png)')
        } else if (res.code == 10009 ) {

          TV.userLogin();
          direEnter(index);
          // alert('111')
        } else {
          var message = res.message
          TV.PromptMsg(message)
        }
      })
    }
  }
</script>
<script type="text/javascript" src="../js/index.js"></script>

</html>